package com.example.demo.Service;

import com.example.demo.DAO.UserRepo;
import com.example.demo.Entity.User;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UserServiceImpl implements UserService{

    UserRepo userRepo ;
    @Override
    public User getUserById(long id){
        return userRepo.findById(id).orElseThrow(RuntimeException::new);
    }

    @Override
    public List<User> getUserByName(String name) {
        return userRepo.findByName(name);
    }

    @Override
    public User getUserByEmail(String Email) {
        return userRepo.findByEmail(Email);
    }

    @Override
    public User getUserByPhone(String ph) {
        return userRepo.findByPhoneNumber(ph);
    }

    @Override
    public List<User> getUserByRole(String role) {
        return userRepo.findByRole(role);
    }

    @Override
    public List<User> getUserByRegistrationDate(Date registrationDate) {
        return userRepo.findByRegistrationDate(registrationDate);
    }
}
